支持多发送支持多抄送支持附件 public Form1()
{
InitializeComponent();
LoadFile();
}
private void LoadFile()
{
if (File.Exists(Path.GetFullPath(path)))
{
string context = File.ReadAllText(path);
Dictionary<string, Object> dic = JsonConvert.DeserializeObject<Dictionary<string, Object>>(context);
SJR.Text = dic["收件人"].ToString();
CC.Text = dic["抄送"].ToString();
ZWTextBox1.Text = dic["正文"].ToString();
BT.Text = dic["标题"].ToString();
fujian.Text = dic["附件"].ToString();
richTextBox2.Text=dic["签名"].ToString();
}
}
private void button1_Click(object sender, EventArgs e)
{
using (OpenFileDialog ofd = new OpenFileDialog())
{
ofd.Title = "请选择文件";
if (ofd.ShowDialog() == DialogResult.OK) //如果点击的是打开文件
{
this.fujian.Text = ofd.FileName; //获取全路径文件名
}
}
}
private void button2_Click(object sender, EventArgs e)
{
if (!Check())//检查必填
return;
//记录文件
if (checkBox1.Checked==true)
{
SaveFile();
}
EmailInfo ei = new EmailInfo();
ei.Context = ZWTextBox1.Text;//正文
ei.SendDuplicate = CC.Text;//抄送人
ei.Recipients = SJR.Text;//收件人
ei.Signature = richTextBox2.Text;//签名
ei.FileUrl = fujian.Text;//附件
ei.Tittle = BT.Text;//标题
if (ei.init())
MessageBox.Show("发送成功!");
}
评论